<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
session_start();
class Admin extends CI_Controller {

    function __construct()
	    {
		parent::__construct();
		$this->load->helper('url');
		$this->load->helper(array('form', 'url'));
		$this->load->library('form_validation');
		$this->load->library('session');
                $this->load->library('input');
                $this->load->model('mod_admin');
	    }
        function index(){
            $this->load->view('admin/vue_login');
        }
        function connexionAdmin(){
           $this->form_validation->set_rules('username','"Username"','trim|required|xss_clean');
           $this->form_validation->set_rules('password','"Mot de passe"','trim|required|xss_clean');
            if($this->form_validation->run()==FALSE){
                    $this->load->view('admin/vue_login');
                } else {
                    $login = $this->input->post('username');
                    $mdp = $this->input->post('password');
                    $id_user = $this->mod_admin->verifCompteAdmin($login,$mdp);
                    if($id_user!=0){
                    $newdata=array();
                    $_SESSION['login'] = $login;	
                    $_SESSION['logged_in'] = 'admin';	
                    $_SESSION['id'] = $id_user;
                    $this->load->view('admin/vue_page_admin');
                    }
                    
                } 
        }
}